package com.example;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class InventoryServiceImpl implements InventoryService {

    private final RedisSegmentLock redisSegmentLock;

    @Override
    public boolean deductStock(String sku, String userId, int quantity) {
        return redisSegmentLock.deductStock(sku, userId, quantity);
    }

    @Override
    public void initStock(String sku, int totalStock) {
        redisSegmentLock.initStock(sku, totalStock);
    }

    @Override
    public long getTotalStock(String sku) {
        return redisSegmentLock.getTotalStock(sku);
    }
}
